<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>module RubyVM::YJIT - RDoc Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="module">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0-preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-code_gc">::code_gc</a>
    <li ><a href="#method-c-disasm">::disasm</a>
    <li ><a href="#method-c-dump_exit_locations">::dump_exit_locations</a>
    <li ><a href="#method-c-enabled-3F">::enabled?</a>
    <li ><a href="#method-c-exit_locations">::exit_locations</a>
    <li ><a href="#method-c-format_number">::format_number</a>
    <li ><a href="#method-c-format_number_pct">::format_number_pct</a>
    <li ><a href="#method-c-insns_compiled">::insns_compiled</a>
    <li ><a href="#method-c-reset_stats-21">::reset_stats!</a>
    <li ><a href="#method-c-resume">::resume</a>
    <li ><a href="#method-c-runtime_stats">::runtime_stats</a>
    <li ><a href="#method-c-stats_enabled-3F">::stats_enabled?</a>
    <li ><a href="#method-c-stats_string">::stats_string</a>
    <li ><a href="#method-c-trace_exit_locations_enabled-3F">::trace_exit_locations_enabled?</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="module-RubyVM::YJIT">
    <h1 id="module-RubyVM::YJIT" class="module">
      module RubyVM::YJIT
    </h1>

    <section class="description">
    
<p>This module allows for introspection of <a href="YJIT.html"><code>YJIT</code></a>, CRuby’s in-process just-in-time compiler. This module exists only to help develop <a href="YJIT.html"><code>YJIT</code></a>, as such, everything in the module is highly implementation specific and comes with no API stability guarantee whatsoever.</p>

<p>This module may not exist if <a href="YJIT.html"><code>YJIT</code></a> does not support the particular platform for which CRuby is built. There is also no API stability guarantee as to in what situations this module is defined.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-code_gc" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">code_gc</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Free and recompile all existing JIT code</p>

                              <div class="method-source-code" id="code_gc-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/yjit.rb, line 218</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">code_gc</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">rb_yjit_code_gc</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-disasm" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">disasm</span><span
                                class="method-args">(iseq)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Produce disassembly for an iseq</p>

                              <div class="method-source-code" id="disasm-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/yjit.rb, line 195</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">disasm</span>(<span class="ruby-identifier">iseq</span>)
  <span class="ruby-comment"># If a method or proc is passed in, get its iseq</span>
  <span class="ruby-identifier">iseq</span> = <span class="ruby-constant">RubyVM</span><span class="ruby-operator">::</span><span class="ruby-constant">InstructionSequence</span>.<span class="ruby-identifier">of</span>(<span class="ruby-identifier">iseq</span>)

  <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">enabled?</span>
    <span class="ruby-comment"># Produce the disassembly string</span>
    <span class="ruby-comment"># Include the YARV iseq disasm in the string for additional context</span>
    <span class="ruby-identifier">iseq</span>.<span class="ruby-identifier">disasm</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot;\n&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">rb_yjit_disasm_iseq</span>(<span class="ruby-identifier">iseq</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">iseq</span>.<span class="ruby-identifier">disasm</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-dump_exit_locations" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">dump_exit_locations</span><span
                                class="method-args">(filename)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p><a href="../Marshal.html"><code>Marshal</code></a> dumps exit locations to the given filename.</p>

<p>Usage:</p>

<p>If ‘–yjit-exit-locations` is passed, a file named “yjit_exit_locations.dump” will automatically be generated.</p>

<p>If you want to collect traces manually, call ‘dump_exit_locations` directly.</p>

<p>Note that calling this in a script will generate stats after the dump is created, so the stats data may include exits from the dump itself.</p>

<p>In a script call:</p>

<pre class="ruby"><span class="ruby-identifier">at_exit</span> <span class="ruby-keyword">do</span>
  <span class="ruby-constant">RubyVM</span><span class="ruby-operator">::</span><span class="ruby-constant">YJIT</span>.<span class="ruby-identifier">dump_exit_locations</span>(<span class="ruby-string">&quot;my_file.dump&quot;</span>)
<span class="ruby-keyword">end</span>
</pre>

<p>Then run the file with the following options:</p>

<pre>ruby --yjit --yjit-trace-exits test.rb</pre>

<p>Once the code is done running, use Stackprof to read the dump file. See Stackprof documentation for options.</p>

                              <div class="method-source-code" id="dump_exit_locations-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/yjit.rb, line 143</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">dump_exit_locations</span>(<span class="ruby-identifier">filename</span>)
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">trace_exit_locations_enabled?</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;--yjit-trace-exits must be enabled to use dump_exit_locations.&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-constant">File</span>.<span class="ruby-identifier">binwrite</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-constant">Marshal</span>.<span class="ruby-identifier">dump</span>(<span class="ruby-constant">RubyVM</span><span class="ruby-operator">::</span><span class="ruby-constant">YJIT</span>.<span class="ruby-identifier">exit_locations</span>))
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-enabled-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">enabled?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Check if <a href="YJIT.html"><code>YJIT</code></a> is enabled</p>

                              <div class="method-source-code" id="enabled-3F-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/yjit.rb, line 13</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">enabled?</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">cexpr!</span> <span class="ruby-string">&#39;RBOOL(rb_yjit_enabled_p())&#39;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-exit_locations" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">exit_locations</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>If –yjit-trace-exits is enabled parse the hashes from Primitive.rb_yjit_get_exit_locations into a format readable by Stackprof. This will allow us to find the exact location of a side exit in <a href="YJIT.html"><code>YJIT</code></a> based on the instruction that is exiting.</p>

                              <div class="method-source-code" id="exit_locations-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/yjit.rb, line 41</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">exit_locations</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">trace_exit_locations_enabled?</span>

  <span class="ruby-identifier">results</span> = <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">rb_yjit_get_exit_locations</span>
  <span class="ruby-identifier">raw_samples</span> = <span class="ruby-identifier">results</span>[<span class="ruby-value">:raw</span>].<span class="ruby-identifier">dup</span>
  <span class="ruby-identifier">line_samples</span> = <span class="ruby-identifier">results</span>[<span class="ruby-value">:lines</span>].<span class="ruby-identifier">dup</span>
  <span class="ruby-identifier">frames</span> = <span class="ruby-identifier">results</span>[<span class="ruby-value">:frames</span>].<span class="ruby-identifier">dup</span>
  <span class="ruby-identifier">samples_count</span> = <span class="ruby-value">0</span>

  <span class="ruby-comment"># Loop through the instructions and set the frame hash with the data.</span>
  <span class="ruby-comment"># We use nonexistent.def for the file name, otherwise insns.def will be displayed</span>
  <span class="ruby-comment"># and that information isn&#39;t useful in this context.</span>
  <span class="ruby-constant">RubyVM</span><span class="ruby-operator">::</span><span class="ruby-constant">INSTRUCTION_NAMES</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">frame_id</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">frame_hash</span> = { <span class="ruby-value">samples:</span> <span class="ruby-value">0</span>, <span class="ruby-value">total_samples:</span> <span class="ruby-value">0</span>, <span class="ruby-value">edges:</span> {}, <span class="ruby-value">name:</span> <span class="ruby-identifier">name</span>, <span class="ruby-value">file:</span> <span class="ruby-string">&quot;nonexistent.def&quot;</span>, <span class="ruby-value">line:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">lines:</span> {} }
    <span class="ruby-identifier">results</span>[<span class="ruby-value">:frames</span>][<span class="ruby-identifier">frame_id</span>] = <span class="ruby-identifier">frame_hash</span>
    <span class="ruby-identifier">frames</span>[<span class="ruby-identifier">frame_id</span>] = <span class="ruby-identifier">frame_hash</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># Loop through the raw_samples and build the hashes for StackProf.</span>
  <span class="ruby-comment"># The loop is based off an example in the StackProf documentation and therefore</span>
  <span class="ruby-comment"># this functionality can only work with that library.</span>
  <span class="ruby-comment">#</span>
  <span class="ruby-comment"># Raw Samples:</span>
  <span class="ruby-comment"># [ length, frame1, frame2, frameN, ..., instruction, count</span>
  <span class="ruby-comment">#</span>
  <span class="ruby-comment"># Line Samples</span>
  <span class="ruby-comment"># [ length, line_1, line_2, line_n, ..., dummy value, count</span>
  <span class="ruby-identifier">i</span> = <span class="ruby-value">0</span>
  <span class="ruby-keyword">while</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">raw_samples</span>.<span class="ruby-identifier">length</span>
    <span class="ruby-identifier">stack_length</span> = <span class="ruby-identifier">raw_samples</span>[<span class="ruby-identifier">i</span>]
    <span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> <span class="ruby-comment"># consume the stack length</span>

    <span class="ruby-identifier">sample_count</span> = <span class="ruby-identifier">raw_samples</span>[<span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">stack_length</span>]

    <span class="ruby-identifier">prev_frame_id</span> = <span class="ruby-keyword">nil</span>
    <span class="ruby-identifier">stack_length</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">idx</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">idx</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">i</span>
      <span class="ruby-identifier">frame_id</span> = <span class="ruby-identifier">raw_samples</span>[<span class="ruby-identifier">idx</span>]

      <span class="ruby-keyword">if</span> <span class="ruby-identifier">prev_frame_id</span>
        <span class="ruby-identifier">prev_frame</span> = <span class="ruby-identifier">frames</span>[<span class="ruby-identifier">prev_frame_id</span>]
        <span class="ruby-identifier">prev_frame</span>[<span class="ruby-value">:edges</span>][<span class="ruby-identifier">frame_id</span>] <span class="ruby-operator">||=</span> <span class="ruby-value">0</span>
        <span class="ruby-identifier">prev_frame</span>[<span class="ruby-value">:edges</span>][<span class="ruby-identifier">frame_id</span>] <span class="ruby-operator">+=</span> <span class="ruby-identifier">sample_count</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">frame_info</span> = <span class="ruby-identifier">frames</span>[<span class="ruby-identifier">frame_id</span>]
      <span class="ruby-identifier">frame_info</span>[<span class="ruby-value">:total_samples</span>] <span class="ruby-operator">+=</span> <span class="ruby-identifier">sample_count</span>

      <span class="ruby-identifier">frame_info</span>[<span class="ruby-value">:lines</span>][<span class="ruby-identifier">line_samples</span>[<span class="ruby-identifier">idx</span>]] <span class="ruby-operator">||=</span> [<span class="ruby-value">0</span>, <span class="ruby-value">0</span>]
      <span class="ruby-identifier">frame_info</span>[<span class="ruby-value">:lines</span>][<span class="ruby-identifier">line_samples</span>[<span class="ruby-identifier">idx</span>]][<span class="ruby-value">0</span>] <span class="ruby-operator">+=</span> <span class="ruby-identifier">sample_count</span>

      <span class="ruby-identifier">prev_frame_id</span> = <span class="ruby-identifier">frame_id</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">stack_length</span> <span class="ruby-comment"># consume the stack</span>

    <span class="ruby-identifier">top_frame_id</span> = <span class="ruby-identifier">prev_frame_id</span>
    <span class="ruby-identifier">top_frame_line</span> = <span class="ruby-value">1</span>

    <span class="ruby-identifier">frames</span>[<span class="ruby-identifier">top_frame_id</span>][<span class="ruby-value">:samples</span>] <span class="ruby-operator">+=</span> <span class="ruby-identifier">sample_count</span>
    <span class="ruby-identifier">frames</span>[<span class="ruby-identifier">top_frame_id</span>][<span class="ruby-value">:lines</span>] <span class="ruby-operator">||=</span> {}
    <span class="ruby-identifier">frames</span>[<span class="ruby-identifier">top_frame_id</span>][<span class="ruby-value">:lines</span>][<span class="ruby-identifier">top_frame_line</span>] <span class="ruby-operator">||=</span> [<span class="ruby-value">0</span>, <span class="ruby-value">0</span>]
    <span class="ruby-identifier">frames</span>[<span class="ruby-identifier">top_frame_id</span>][<span class="ruby-value">:lines</span>][<span class="ruby-identifier">top_frame_line</span>][<span class="ruby-value">1</span>] <span class="ruby-operator">+=</span> <span class="ruby-identifier">sample_count</span>

    <span class="ruby-identifier">samples_count</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">sample_count</span>
    <span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">results</span>[<span class="ruby-value">:samples</span>] = <span class="ruby-identifier">samples_count</span>
  <span class="ruby-comment"># Set missed_samples and gc_samples to 0 as their values</span>
  <span class="ruby-comment"># don&#39;t matter to us in this context.</span>
  <span class="ruby-identifier">results</span>[<span class="ruby-value">:missed_samples</span>] = <span class="ruby-value">0</span>
  <span class="ruby-identifier">results</span>[<span class="ruby-value">:gc_samples</span>] = <span class="ruby-value">0</span>
  <span class="ruby-identifier">results</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-insns_compiled" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">insns_compiled</span><span
                                class="method-args">(iseq)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Produce a list of instructions compiled by <a href="YJIT.html"><code>YJIT</code></a> for an iseq</p>

                              <div class="method-source-code" id="insns_compiled-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/yjit.rb, line 209</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">insns_compiled</span>(<span class="ruby-identifier">iseq</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">unless</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">enabled?</span>

  <span class="ruby-comment"># If a method or proc is passed in, get its iseq</span>
  <span class="ruby-identifier">iseq</span> = <span class="ruby-constant">RubyVM</span><span class="ruby-operator">::</span><span class="ruby-constant">InstructionSequence</span>.<span class="ruby-identifier">of</span>(<span class="ruby-identifier">iseq</span>)
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">rb_yjit_insns_compiled</span>(<span class="ruby-identifier">iseq</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-reset_stats-21" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">reset_stats!</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Discard statistics collected for –yjit-stats.</p>

                              <div class="method-source-code" id="reset_stats-21-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/yjit.rb, line 28</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">reset_stats!</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">rb_yjit_reset_stats_bang</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-resume" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">resume</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Resume <a href="YJIT.html"><code>YJIT</code></a> compilation after paused on startup with –yjit-pause</p>

                              <div class="method-source-code" id="resume-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/yjit.rb, line 33</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">resume</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">rb_yjit_resume</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-runtime_stats" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">runtime_stats</span><span
                                class="method-args">(context: false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Return a hash for statistics generated for the –yjit-stats command line option. Return nil when option is not passed or unavailable.</p>

                              <div class="method-source-code" id="runtime_stats-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/yjit.rb, line 153</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">runtime_stats</span>(<span class="ruby-value">context:</span> <span class="ruby-keyword">false</span>)
  <span class="ruby-identifier">stats</span> = <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">rb_yjit_get_stats</span>(<span class="ruby-identifier">context</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">stats</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">stats</span>.<span class="ruby-identifier">nil?</span>

  <span class="ruby-identifier">stats</span>[<span class="ruby-value">:object_shape_count</span>] = <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">object_shape_count</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">stats</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">rb_yjit_stats_enabled_p</span>

  <span class="ruby-identifier">side_exits</span> = <span class="ruby-identifier">total_exit_count</span>(<span class="ruby-identifier">stats</span>)
  <span class="ruby-identifier">total_exits</span> = <span class="ruby-identifier">side_exits</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">stats</span>[<span class="ruby-value">:leave_interp_return</span>]

  <span class="ruby-comment"># Number of instructions that finish executing in YJIT.</span>
  <span class="ruby-comment"># See :count-placement: about the subtraction.</span>
  <span class="ruby-identifier">retired_in_yjit</span> = <span class="ruby-identifier">stats</span>[<span class="ruby-value">:yjit_insns_count</span>] <span class="ruby-operator">-</span> <span class="ruby-identifier">side_exits</span>

  <span class="ruby-comment"># Average length of instruction sequences executed by YJIT</span>
  <span class="ruby-identifier">avg_len_in_yjit</span> = <span class="ruby-identifier">total_exits</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">retired_in_yjit</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">total_exits</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>

  <span class="ruby-comment"># Proportion of instructions that retire in YJIT</span>
  <span class="ruby-identifier">total_insns_count</span> = <span class="ruby-identifier">retired_in_yjit</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">stats</span>[<span class="ruby-value">:vm_insns_count</span>]
  <span class="ruby-identifier">yjit_ratio_pct</span> = <span class="ruby-value">100.0</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">retired_in_yjit</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">total_insns_count</span>
  <span class="ruby-identifier">stats</span>[<span class="ruby-value">:total_insns_count</span>] = <span class="ruby-identifier">total_insns_count</span>
  <span class="ruby-identifier">stats</span>[<span class="ruby-value">:ratio_in_yjit</span>] = <span class="ruby-identifier">yjit_ratio_pct</span>

  <span class="ruby-comment"># Make those stats available in RubyVM::YJIT.runtime_stats as well</span>
  <span class="ruby-identifier">stats</span>[<span class="ruby-value">:side_exit_count</span>]  = <span class="ruby-identifier">side_exits</span>
  <span class="ruby-identifier">stats</span>[<span class="ruby-value">:total_exit_count</span>] = <span class="ruby-identifier">total_exits</span>
  <span class="ruby-identifier">stats</span>[<span class="ruby-value">:avg_len_in_yjit</span>]  = <span class="ruby-identifier">avg_len_in_yjit</span>

  <span class="ruby-identifier">stats</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-stats_enabled-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">stats_enabled?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Check if –yjit-stats is used.</p>

                              <div class="method-source-code" id="stats_enabled-3F-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/yjit.rb, line 18</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">stats_enabled?</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">rb_yjit_stats_enabled_p</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-stats_string" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">stats_string</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Format and print out counters as a <a href="../String.html"><code>String</code></a>. This returns a non-empty content only when –yjit-stats is enabled.</p>

                              <div class="method-source-code" id="stats_string-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/yjit.rb, line 186</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">stats_string</span>
  <span class="ruby-comment"># Lazily require StringIO to avoid breaking miniruby</span>
  <span class="ruby-identifier">require</span> <span class="ruby-string">&#39;stringio&#39;</span>
  <span class="ruby-identifier">strio</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-identifier">_print_stats</span>(<span class="ruby-value">out:</span> <span class="ruby-identifier">strio</span>)
  <span class="ruby-identifier">strio</span>.<span class="ruby-identifier">string</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-trace_exit_locations_enabled-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">trace_exit_locations_enabled?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Check if rb_yjit_trace_exit_locations_enabled_p is enabled.</p>

                              <div class="method-source-code" id="trace_exit_locations_enabled-3F-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/yjit.rb, line 23</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">trace_exit_locations_enabled?</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">rb_yjit_trace_exit_locations_enabled_p</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Class Methods</h3>
                </header>

                  <div id="method-c-format_number" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">format_number</span><span
                                class="method-args">(pad, number)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Format large numbers with comma separators for readability</p>

                              <div class="method-source-code" id="format_number-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/yjit.rb, line 408</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">format_number</span>(<span class="ruby-identifier">pad</span>, <span class="ruby-identifier">number</span>)
  <span class="ruby-identifier">integer</span>, <span class="ruby-identifier">decimal</span> = <span class="ruby-identifier">number</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;.&quot;</span>)
  <span class="ruby-identifier">d_groups</span> = <span class="ruby-identifier">integer</span>.<span class="ruby-identifier">chars</span>.<span class="ruby-identifier">to_a</span>.<span class="ruby-identifier">reverse</span>.<span class="ruby-identifier">each_slice</span>(<span class="ruby-value">3</span>)
  <span class="ruby-identifier">with_commas</span> = <span class="ruby-identifier">d_groups</span>.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:join</span>).<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39;,&#39;</span>).<span class="ruby-identifier">reverse</span>
  <span class="ruby-identifier">formatted</span> = [<span class="ruby-identifier">with_commas</span>, <span class="ruby-identifier">decimal</span>].<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;.&quot;</span>)
  <span class="ruby-identifier">formatted</span>.<span class="ruby-identifier">rjust</span>(<span class="ruby-identifier">pad</span>, <span class="ruby-string">&#39; &#39;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-format_number_pct" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">format_number_pct</span><span
                                class="method-args">(pad, number, total)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Format a number along with a percentage over a total value</p>

                              <div class="method-source-code" id="format_number_pct-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/yjit.rb, line 417</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">format_number_pct</span>(<span class="ruby-identifier">pad</span>, <span class="ruby-identifier">number</span>, <span class="ruby-identifier">total</span>)
  <span class="ruby-identifier">padded_count</span> = <span class="ruby-identifier">format_number</span>(<span class="ruby-identifier">pad</span>, <span class="ruby-identifier">number</span>)
  <span class="ruby-identifier">percentage</span> = <span class="ruby-identifier">number</span>.<span class="ruby-identifier">fdiv</span>(<span class="ruby-identifier">total</span>) <span class="ruby-operator">*</span> <span class="ruby-value">100</span>
  <span class="ruby-identifier">formatted_pct</span> = <span class="ruby-string">&quot;%4.1f%%&quot;</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">percentage</span>
  <span class="ruby-node">&quot;#{padded_count} (#{formatted_pct})&quot;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is a service of <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>, purveyors of fine <a href='https://jamesbritt.bandcamp.com/'>dance noise</a></p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

